/**
   UserController
 * Time:2018年6月13日
 */
package com.ssm.controller;

import java.io.IOException;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.registry.infomodel.User;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.ssm.entity.Usermessage;
import com.ssm.service.UserMessageService;

/**
 * @author 15199
 *
 */
@Controller
@RequestMapping("/user")
public class UserController {

	@Resource 
	private UserMessageService userMessageService;


	@RequestMapping("/Login.do")
	public ModelAndView checkLogin(@RequestParam("user") Integer user,@RequestParam("pwd") Integer pwd,HttpServletRequest request,HttpServletResponse response) throws IOException{


		Usermessage usermessage=new Usermessage(user,pwd,0);

		List<Usermessage> list=userMessageService.checkLogin(usermessage);	

		if(list.size()>0){

			request.getSession().setAttribute("usermessage",usermessage);
			String id=(String) request.getSession().getAttribute("id"); 

			response.sendRedirect("/videomessage/player.do?id="+id); 

			return null;
		}else{

			return new ModelAndView("/jsp/FG/Login.jsp");
		}



	}
	@RequestMapping("/sendlLogin.do")
	public ModelAndView sendlLogin(HttpServletResponse response) throws IOException{



		response.sendRedirect("/jsp/FG/Login.jsp");



		return null;


	}



}
